package tau.adx.common.advertisers.generators;

import java.util.Collection;
import java.util.LinkedList;
import java.util.Random;

import lombok.Data;
import lombok.NoArgsConstructor;
import tau.adx.common.advertisers.Advertiser;
import tau.adx.common.advertisers.SimpleAdvertiser;
import tau.adx.common.generators.GenericGenerator;

/**
 * A naive implementation of the {@link GenericGenerator} interface. Randomizes
 * each characteristic of an {@link Advertiser}.
 * 
 * @author greenwald
 * 
 */
@Data
@NoArgsConstructor
public class SimpleAdvertiserGenerator implements GenericGenerator<Advertiser> {

	/**
	 * An instance of the {@link Random} class.
	 */
	private Random random = new Random();

	/**
	 * @see tau.adx.common.generators.GenericGenerator#generate(int)
	 */
	@Override
	public Collection<Advertiser> generate(int amount) {
		Collection<Advertiser> advertisers = new LinkedList<>();
		for (int i = 0; i < amount; i++) {
			advertisers.add(getRandomAdvertiser());
		}
		return advertisers;
	}

	/**
	 * @return A random advertiser.
	 */
	private Advertiser getRandomAdvertiser() {
		Advertiser advertiser = new SimpleAdvertiser("Advertiser #"
				+ Math.abs(random.nextInt()));
		return advertiser;
	}
}
